//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<ISlotLayout.cpp>
///	@path	~/src/graphics/
///	@date	2008/12/28
///	@desc	.

#include "config/config.h"

#include "graphics/ISlotLayout.h"

namespace xeres {

	IMPL_IOBJECT_INTERFACE( ISlotLayout );

	// ISlotLayout
	ISlotLayout::ISlotLayout( void )
	{

	}
	// ~ISlotLayout
	ISlotLayout::~ISlotLayout( void )
	{

	}

	static const char * s_VertexDeclStr[VertexSlotType_last] = 
	{
		"VertexSlotType_Float1",
		"VertexSlotType_Float2",
		"VertexSlotType_Float3",
		"VertexSlotType_Float4",
		"VertexSlotType_Byte4",
		"VertexSlotType_Byte4Norm",
		"VertexSlotType_Short2",
		"VertexSlotType_Short2Norm",
		"VertexSlotType_Short4",
		"VertexSlotType_Short4Norm",
		"VertexSlotType_UShort2Norm",
		"VertexSlotType_UShort4Norm",
		"VertexSlotType_Half2",
		"VertexSlotType_Half4",
		"VertexSlotType_ColorRGBA",
		"VertexSlotType_ColorfRGBA",
	};
	// to_str
	AString VertexSlotDeclaration::to_str( void ) const
	{
		char buf[256];
		const char * tp = s_VertexDeclStr[type];
		sprintf( buf , "%u,%u,%s:%s;" , offset , slot , tp , semantic );
		return AString(buf);
	}
	// make_signature
	AString VertexSlotDeclaration::make_signature( const std::vector<VertexSlotDeclaration>& decls )
	{
		AString retval;
		for( size_t i = 0 , total = decls.size() ; i < total ; ++i )
		{
			const VertexSlotDeclaration& decl = decls[i];
			retval += decls[i].to_str();
		}
		return retval;
	}
} // namespace xeres
